#include <QDesktopServices>
#include <QUrl>
#include "storelauncher.h"


QStoreLauncher::QStoreLauncher(QObject *parent) :
    QObject(parent)
{
    myProcess = new QProcess(this);
    QObject::connect(myProcess, SIGNAL(stateChanged(QProcess::ProcessState)),
                     this, SLOT(stateChanged(QProcess::ProcessState)));
}

void QStoreLauncher::LaunchNokiaStore(QString params)
{
    arguments = params;
    const QString NokiaStoreLauncherApp ("ovistore_2002D07F");
    myProcess->start(NokiaStoreLauncherApp, arguments.split(QString("\n")));
}

void QStoreLauncher::processError(QProcess::ProcessError error)
{ // Hey, something goes wrong
    switch (error)
    {
    case QProcess::FailedToStart:
    case QProcess::Crashed:
    case QProcess::Timedout:
    case QProcess::ReadError:
    case QProcess::WriteError:
    case QProcess::UnknownError:
    {
        //Here you will need SwEvent capability declaration in case browser is already open
        QDesktopServices::openUrl(QUrl(arguments));
        break;
    }
    default:
    {
        break;
    }
    }
}
